#include "gtest/gtest.h"

#include "stream/Topic.h"
#include "stream/Appender.h"

using namespace stream;

TEST(AppenderTest, test){
	auto stream = std::shared_ptr<Topic>(::stream::makeTopic("hello", "."));
	auto appender = std::shared_ptr<Appender>(::stream::makeAppender(stream));	
	ASSERT_TRUE(appender->open());

    size_t expect = 7;
    for(size_t i = 0; i < expect; ++i){
        ASSERT_TRUE(appender->append(i, "GTP" + std::to_string(i+1)) > 1);
    }
	ASSERT_EQ(appender->size(), expect);
	ASSERT_EQ(stream->size(), expect);

	appender->close();
}
